package edu.lingnan.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import edu.lingnan.dto.result.AnswerInfo;
import edu.lingnan.entity.Answer;
import edu.lingnan.service.AnswerService;
import edu.lingnan.service.FeedbackService;
import edu.lingnan.vo.Result;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Author: 卢荣康
 * @Date: 2022/10/2 下午 7:42
 * @Description:
 */
@RestController
@RequestMapping("/answer")
@Api(tags = "回复控制器")
public class AnswerController {

    @Resource
    private AnswerService answerService;

    @Resource
    private FeedbackService feedbackService;

    @PostMapping
    public Result answer(@RequestBody @Valid Answer answer){
        answerService.answer(answer);
        return new Result(true, null, "回复成功");
    }

    @GetMapping
    public Result getAnswer(@RequestParam Integer currentPage, @RequestParam Integer size, @RequestParam String sId){
        Page<AnswerInfo> answerInfos = feedbackService.get(currentPage, size, sId);
        return new Result(true, answerInfos, "操作成功");
    }


}
